#include "SemanticNodeProgram.h"

#include "SemanticNodeNamespace.h"


SemanticNodeProgram::SemanticNodeProgram(const SyntaxTreeNode &programNode) :	SemanticNode(NULL) {
	for (int i = 0; i < programNode.Nodes->GetCount(); i++) {
		if (programNode.Nodes->GetData(i)->Production == Gr_GppFile__UsingDirectives_FileBody_endOfFile) {
			namespaces.push_back(new SemanticNodeNamespace(*(programNode.Nodes->GetData(i)), this));
		}
	}
}

SemanticNodeProgram::~SemanticNodeProgram() {
	for (std::vector<SemanticNodeNamespace*>::iterator i = namespaces.begin(); i != namespaces.end(); ++i) {
		delete *i;
	}
}








std::string SemanticNodeProgram::toDebugString(int tab) {
	std::ostringstream ss;
	for (int i = 0; i < tab; i++) ss << DEBUG_STRING_RAZMAK;
	ss << "PROGRAM" << std::endl;
	for (int i = 0; i < tab + 1; i++) ss << DEBUG_STRING_RAZMAK;
	ss << "Namespaces: {" << std::endl;
	for (std::vector<SemanticNodeNamespace*>::iterator i = namespaces.begin(); i != namespaces.end(); ++i)
		ss << (*i)->toDebugString(tab + 2);
	for (int i = 0; i < tab + 1; i++) ss << DEBUG_STRING_RAZMAK;
		ss << "}" << std::endl;
	return ss.str();
}

